package com.henry.position;

public class Position {
    private int x;
    private int y;

    public Position(int xIn, int yIn) {
        x = xIn;
        y = yIn;
    }

    public Position(Position other) {
        x = other.x;
        y = other.y;
    }

    public Position move(int dx, int dy) {
        this.x = this.x + dx;
        this.y = this.y + dy;
        return this;
    }

    public double distance(Position p) {
        double deltaX = Math.abs(this.x - p.x);
        double deltaY = Math.abs(this.y - p.y);
        return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
    }

    public Position scale(double f) {
        this.x = (int)(this.x * f);
        this.y = (int)(this.y * f);
        return this;
    }

    @Override
    public String toString() {
        return "(" + x + ", " + y + ")";
    }
}
